package org.bbelovic.devel.exercises.sequences.impl;

public class Hokus {

    public static void main(String[] args) {
        int numbers [] = new int [] {1,2,1,1};
        int prev = -1;
        int act = 0;
        int frequency = 0;
        int digit = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < numbers.length; i++) {
            act = numbers[i];
            if (prev == -1 || act == prev) {
                frequency++;
                prev = act;
            } else {
                digit = prev;
                System.out.println("freq="+ frequency + ", digit="+digit);
                sb.append(frequency).append(digit);
                frequency = 1;
                prev = act;
            }
            
        }
        System.out.println("freq="+ frequency + ", digit="+prev);
        sb.append(frequency).append(prev);
        System.out.println(sb);
    }
}
